package com.servlet.app;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.entity.New;
import com.service.NewService;
import com.service.impl.NewServiceImpl;

/**
 * App 新闻详情
 * 新闻分页控制器
 * 
 */
@WebServlet("/news_app_detail")
public class AppNewsDetailServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public AppNewsDetailServlet() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		request.setCharacterEncoding("UTF-8");
		String id = request.getParameter("nid");
		NewService newService = new NewServiceImpl();
		try {

			New news = newService.selectNewById(Integer.parseInt(id));
			request.setAttribute("news", news);
			request.getRequestDispatcher("app/news_detail.jsp").forward(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
